package com.prabhat.webapp.base;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;

import org.apache.cxf.jaxrs.model.wadl.Description;
import org.apache.cxf.jaxrs.model.wadl.Descriptions;
import org.apache.cxf.jaxrs.model.wadl.DocTarget;
import org.codehaus.jackson.annotate.JsonIgnore;

@Description(value="BaseRequest(Request of common fields",target=DocTarget.RESOURCE)
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(
		name = "BaseRequest",
		propOrder = {"refId", "localeTime", "credentials", "var", "channelType"},
		namespace="http://www.gharari.com"
		)
public class BaseRequest implements Serializable {


	@XmlElement(required=true, nillable = true)
    protected String refId;
	
	//@JsonIgnore
	protected Credentials credentials;
    
	@XmlElement(required=true, nillable = true)
    @XmlSchemaType(name = "dateTime")
    protected Date localeTime;
    
//    @XmlTransient @JsonIgnore
	@JsonIgnore
    protected List<String> var;
    
    @XmlElement(required=true, nillable = true)
    protected int channelType;
    
    
   //@JsonIgnore
    @XmlTransient
    //@JsonIgnore
    protected String program;

    @XmlTransient
    //@JsonIgnore
    private long programId;

    
    
    
    /**
     * Gets the value of the refId property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    @Descriptions({
		@Description(value = "Reference id of the request", target = DocTarget.PARAM),
		@Description(value = "123456 or 5432322 etc", target = DocTarget.PARAM)
	})
    public String getRefId() {
        return refId;
    }

    /**
     * Sets the value of the refId property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setRefId(String value) {
        this.refId = value;
    }

    /**
     * Gets the value of the credentials property.
     * 
     * @return
     *     possible object is
     *     {@link Credentials }
     *     
     */
    @Descriptions({
		@Description(value = "Credentials of the session", target = DocTarget.PARAM),
		@Description(value = "{'username':'xxx','password':'abc'}", target = DocTarget.PARAM)
	})
    public Credentials getCredentials() {
        return credentials;
    }

    /**
     * Sets the value of the credentials property.
     * 
     * @param value
     *     allowed object is
     *     {@link Credentials }
     *     
     */
    public void setCredentials(Credentials value) {
        this.credentials = value;
    }

    /**
     * Gets the value of the var property.
     * 
     * <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the var property.
     * 
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getVar().add(newItem);
     * </pre>
     * 
     * 
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {@link String }
     * 
     * 
     */
    @Descriptions({
		@Description(value = "Auxillary list used to pass additional fields in the request", target = DocTarget.PARAM),
		@Description(value = "['proxy:00005','cardnum:5232322145641432']", target = DocTarget.PARAM)
	})
    public List<String> getVar() {
        if (var == null) {
            var = new ArrayList<String>();
        }
        return this.var;
    }

    @Descriptions({
		@Description(value = "<b>M</b><br>Channel type of the request.", target = DocTarget.PARAM),
		@Description(value = "WEB - 1 <br> MOBILE APP - 2 <br> MOBILE WEB - 3 <br> SMS - 4<br>", target = DocTarget.PARAM)
	})
	public Integer getChannelType() {
		return channelType;
	}

	public void setChannelType(Integer channelType) {
		this.channelType = channelType;
	}

	/**
	 * @return the program
	 */
	@Descriptions({
		@Description(value = "Name of the Program", target = DocTarget.PARAM),
		@Description(value = "RPSL or O2 etc", target = DocTarget.PARAM)
	})
	public String getProgram() {
		return program;
	}

	/**
	 * @param program the program to sete:
	 * 
	 */
	public void setProgram(String program) {
		this.program = program;
	}

	/**
	 * @param var the var to set
	 */
	public void setVar(List<String> var) {
		this.var = var;
	}
	
	/**
	 * @return the programId
	 */
	@Descriptions({
		@Description(value = "id of the Program", target = DocTarget.PARAM),
		@Description(value = "1 or 2 or 3 etc", target = DocTarget.PARAM)
	})
	public long getProgramId() {
		return programId;
	}
	/**
	 * @param programId the programId to set
	 */
	public void setProgramId(long programId) {
		this.programId = programId;
	}
	 /**
     * @return the requestorId
     */
	@Descriptions({
		@Description(value = "Requester id of the request", target = DocTarget.PARAM),
		@Description(value = "5123467 or 1347531 etc", target = DocTarget.PARAM)
	})
    public String getRequestorId() {
    	if (credentials != null) {
            return credentials.getUserName();
    	}
    	return null;
    }
    /**
     * @param requestorId the requestorId to set
     */
    public void setRequestorId(String requestorId) {
    	if (credentials == null) {
            credentials = new Credentials();
    	}
    	credentials.setUserName(requestorId);
    }

    @Descriptions({
		@Description(value = "Time of the request.", target = DocTarget.PARAM),
		@Description(value = "2013-06-04T00:00:00.000+05:00", target = DocTarget.PARAM)
	})
	public Date getLocaleTime() {
		return localeTime;
	}

	/**
	 * @param localeTime the localeTime to set
	 */
	public void setLocaleTime(Date localeTime) {
		this.localeTime = localeTime;
	}

}
